package com.kinglone.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import com.kinglone.model.User;
import com.kinglone.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller  
@RequestMapping("/user") 
public class UserController {
	 @Resource  
	 private UserService userService;  
	      
	    @RequestMapping("/showUser.jspx")  
	    public String showUser(HttpServletRequest request,Model model){  
	        int userId = Integer.parseInt(request.getParameter("id"));  
	        User user = this.userService.getUserById(userId);  
	        model.addAttribute("user", user.getUsername());  
	        return "showUser";
	    }
	    @RequestMapping("/regist.jspx")  
	    public String regist(HttpServletRequest request,Model model,User user){  
	    	userService.regist(user); 
	    	model.addAttribute("msg", "注册成功！");
	    	return "showUser";
	    }
}
